﻿@using Microsoft.AspNet.Identity
@model AtlasWichita.Models.CustomerViewModel
@{
    ViewBag.Title = "Index";
}

<br/>
@if (@Model.thisCustomer.testTaken)
{
    <div>

        <h3><b>@User.Identity.GetUserName()'s Personality:</b></h3>
        <script>
            var adjectives = [Math.round(((@Model.thisCustomer.Formal.totalPoints) / 100) * 100), Math.round(((@Model.thisCustomer.Conformist.totalPoints) / 98) * 100),
                            Math.round(((@Model.thisCustomer.BlueCollar.totalPoints) / 89 * 100)), Math.round(((@Model.thisCustomer.Simple.totalPoints) / 90 * 100)),
                            Math.round(((@Model.thisCustomer.Trendy.totalPoints) / 105 * 100)), Math.round(((@Model.thisCustomer.Gritty.totalPoints) / 96 * 100)),
                            Math.round(((@Model.thisCustomer.Independent.totalPoints) / 96.5 * 100)), Math.round(((@Model.thisCustomer.Local.totalPoints) / 78 * 100)),
                            Math.round(((@Model.thisCustomer.Energetic.totalPoints) / 110 * 100)), Math.round(((@Model.thisCustomer.Modern.totalPoints) / 90 * 100)),
                            Math.round(((@Model.thisCustomer.Elegant.totalPoints) / 93 * 100)) ];

            //for (var i = 0; i < adjectives.length; i++)
            //{
            //    document.write('<span>'+adjectives[i]+'  </span>');
            //}

            var top3 = ["1", 1, "2", 2, "3", 3];

            top3[0] = @Html.Raw(Json.Encode(@Model.thisCustomer.highestAdjective));
            top3[2] = @Html.Raw(Json.Encode(@Model.thisCustomer.secondHighestAdjective));
            top3[4] = @Html.Raw(Json.Encode(@Model.thisCustomer.thirdHighestAdjective));

            for (var i = 0; i < top3.length; i++)
            {
                switch(top3[i])
                {
                    case "Formal":
                    case "Casual":
                        top3[i+1] = Math.abs(adjectives[0]);
                        break;
                    case "Conformist":
                    case "Rebellious":
                        top3[i+1] = Math.abs(adjectives[1]);
                        break;
                    case "Blue Collar":
                    case "White Collar":
                        top3[i+1] = Math.abs(adjectives[2]);
                        break;
                    case "Simple":
                    case "Sophisticated":
                        top3[i+1] = Math.abs(adjectives[3]);
                        break;
                    case "Trendy":
                    case "Traditional":
                        top3[i+1] = Math.abs(adjectives[4]);
                        break;
                    case "Gritty":
                    case "Refined":
                        top3[i+1] = Math.abs(adjectives[5]);
                        break;
                    case "Independent":
                    case "Associative":
                        top3[i+1] = Math.abs(adjectives[6]);
                        break;
                    case "Local":
                    case "Global":
                        top3[i+1] = Math.abs(adjectives[7]);
                        break;
                    case "Energetic":
                    case "Relaxed":
                        top3[i+1] = Math.abs(adjectives[8]);
                        break;
                    case "Modern":
                    case "Classical":
                        top3[i+1] = Math.abs(adjectives[9]);
                        break;
                    case "Elegant":
                    case "Ordinary":
                        top3[i+1] = Math.abs(adjectives[10]);
                        break;
                }
            }

            document.write(
            '<div class="progress" style="height: 40px; max-width: 600px;">\
                    <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'+top3[1]+'" aria-valuemin="0" aria-valuemax="100" style="width: '+top3[1]+'%">\
                    <span style="font-size:20px; vertical-align: middle; line-height: 40px;"> ' + top3[0] + '</span>\
                    </div>\
                </div>'
            );

            document.write(
            '<div class="progress" style="height: 40px; max-width: 600px;">\
                    <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'+top3[3]+'" aria-valuemin="0" aria-valuemax="100" style="width: '+top3[3]+'%">\
                    <span style="font-size:20px; vertical-align: middle; line-height: 40px;"> ' + top3[2] + '</span>\
                    </div>\
                </div>'
            );

            document.write(
            '<div class="progress" style="height: 40px; max-width: 600px;">\
                    <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="'+top3[5]+'" aria-valuemin="0" aria-valuemax="100" style="width: '+top3[5]+'%">\
                    <span style="font-size:20px; vertical-align: middle; line-height: 40px;"> ' + top3[4] + '</span>\
                    </div>\
                </div>'
            );

        </script>
    </div>

  
    <div>
        <br/>
        <h3><b>Best restaurants for @User.Identity.GetUserName():</b></h3>
        @for (var i = 0; i < 8; i++)
        {
            var Str = Model.restaurantList.RestaurantList[i].RestaurantName;
            if (((Model.thisCustomer.highestAdjective == Model.restaurantList.RestaurantList[i].tag1) ||
                (Model.thisCustomer.highestAdjective == Model.restaurantList.RestaurantList[i].tag2) ||
                (Model.thisCustomer.highestAdjective == Model.restaurantList.RestaurantList[i].tag3)) ||
                ((Model.thisCustomer.secondHighestAdjective == Model.restaurantList.RestaurantList[i].tag1) ||
                (Model.thisCustomer.secondHighestAdjective == Model.restaurantList.RestaurantList[i].tag2) ||
                (Model.thisCustomer.secondHighestAdjective == Model.restaurantList.RestaurantList[i].tag3)) ||
                ((Model.thisCustomer.thirdHighestAdjective == Model.restaurantList.RestaurantList[i].tag1) ||
                (Model.thisCustomer.thirdHighestAdjective == Model.restaurantList.RestaurantList[i].tag2) ||
                (Model.thisCustomer.thirdHighestAdjective == Model.restaurantList.RestaurantList[i].tag3)))
            {
                var price = Model.restaurantList.RestaurantList[i].price;

                <div class="restaurant">
                    <span style="font-size:30px"><b>@Model.restaurantList.RestaurantList[i].RestaurantName</b></span>
                    <br />
                    <span>Price range: </span>
                    @for (var j = 0; j < price; j++ )
                    {
                        <span class="glyphicon glyphicon-usd" style="color: green"></span>
                    }
                    <br />
                    <span>@Model.restaurantList.RestaurantList[i].address</span>
                    <br/>
                    <span>Phone: @Model.restaurantList.RestaurantList[i].phone</span>
                    <br />
                    <br />
                </div>
            }

        }


    </div>
}

else {
    <h2>You have not taken the test yet!</h2>
}